<template>
  <div class="input-content">
    <vxe-input
      v-model="val"
      :placeholder="placeholder"
      type="number"
      size="mini"
      @change="change"
    />
  </div>
</template>

<script>
export default {
  name: "text-number",
  props: {
    value: Number,
    type: {
      type: String,
    },
    placeholder: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      val: parseInt(this.value),
      focused: false,
    };
  },
  watch: {
    value(val) {
      this.val = parseInt(val);
    },
  },
  methods: {
    change(data) {
      this.$emit("input", parseInt(data.value));
      this.$emit("change", {
        key: this.type,
        value: parseInt(data.value),
      });
    },
  },
};
</script>

<style scoped lang="scss">
.input-content {
  width: 100%;
  box-sizing: border-box;
  border-radius: 2px;
  transition: all 0.28s;
  display: flex;
  overflow: hidden;
  justify-content: space-between;
}
</style>
